import apiProxy from '@/common/restclient'

let baseUrl = apiProxy.baseUrl;
let buildUrl = apiProxy.buildUrl;
let buildFetchUrl = apiProxy.buildFetchUrl;
let postApi = apiProxy.postApi;
let postJsonApi = apiProxy.postJsonApi;
let getApi = apiProxy.getApi;

let factoringApi = '/factoring-api'
let homeApi = '/home-api'

export default {
    buildUrl: buildUrl,
	buildFetchUrl: buildFetchUrl,
    // 获取基础url
    baseUrl: () => baseUrl,
    captchaUrl: (appPath) => buildUrl("/captcha", appPath),
    // 生成文件加载路径
    fileUrl: (fileId, appPath) => buildUrl(`/file/${fileId}`, appPath),
    // 生成文件上传路径
    uploadUrl: (dirName, appPath) => buildUrl(`/file/upload/${dirName}`, appPath),
	
	// 是否已经认证
	isAutenticated() {
		const userInfo = uni.getStorageSync('x-user-info');
		console.log("userInfo: " + userInfo);
		if (userInfo) {
			return userInfo.authenticated;
		}
		return false;
	},
	// 获取用户信息
	getUserInfo() {
		return uni.getStorageSync('x-user-info');
	},

    /** 登录 */
	login: {
		login: getApi("/api/login"),
		checkLogin: getApi("/api/checkLogin")
	},
	route: {
		getAllRoute: getApi("/api/public/route/queryRouteList"),	
		getShiftInfo: getApi("/api/schedule/public/getShiftInfo"),	
		queryByScheduleDatilId: getApi("/api/user/queryByScheduleDatilId"),
		pageQueryByUserId: getApi("/api/schedule/pageQueryByUserId"),
	},
	user:{
		bindPassenger: postJsonApi("/api/user/bindPassenger"),
		queryByUserId: getApi("/api/user/queryByUserId"),
		delPassenger: getApi("/api/user/delPassenger"),
		queryById: getApi("/api/user/queryById"),
		updatePassenger: postJsonApi("/api/user/updatePassenger"),
	},
	order:{
		createOrder: postJsonApi("/api/order/createOrder"),
		queryOrdersByUserId: getApi("/api/order/queryOrdersByUserId"),
		queryOrderStateAndDetailId: getApi("/api/order/queryOrderStateAndDetailId"),
		payOrder: getApi("/api/order/payOrder"),
		cancelOrder: getApi("/api/order/cancelOrder"),
		refundById: getApi("/api/order/refundById"),
		checkInfoByDetailId: getApi("/api/user/checkInfoByDetailId"),
		isCheck: getApi("/api/user/isCheck"),
		queryByDetailId: getApi("/api/schedule/queryByDetailId"),
		updateScheduleDetail: getApi("/api/schedule/updateScheduleDetail"),
		pageScheduleDetail: getApi("/api/schedule/pageScheduleDetail"),
		getCarList: getApi("/api/schedule/getCarList"),
	},
	ticket:{
		addTicket: postJsonApi("/api/user/createPassengerInvoice"),
		updateTicket: postJsonApi("/api/user/updateTsPassengerInvoice"),
		deteteTicket: getApi("/api/user/deletTsPassengerInvoice"),
		ticketList: getApi("/api/user/pageTsPassengerInvoice"),
		saveTsOrderInvoice: getApi("/api/order/saveTsOrderInvoice"),
		getTicketDetail: getApi("/api/user/getById"),
	},
	service:{
		queryBiServiceCode: getApi("/api/public/service/queryBiServiceCode"),
		queryCarTypeInfo: getApi("/api/public/service/queryCarTypeInfo"),
		createFeedback: getApi("/api/user/createFeedback"),
	},
};
